﻿# CMakeList.txt: protobuf_demo 的 CMake 项目，在此处包括源代码并定义
# 项目特定的逻辑。
#
cmake_minimum_required(VERSION 3.21)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)

project("protobuf_demo")

# deps
# # protobuf
find_package(Protobuf REQUIRED)
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS "test.proto")
include_directories(${CMAKE_BINARY_DIR})

# # libuv
find_package(libuv REQUIRED)

# # boost
find_package(Boost REQUIRED)

# targets
# # protobuf
add_executable(protobuf_demo "protobuf_demo.cpp" ${PROTO_SRCS} ${PROTO_HDRS})
target_link_libraries(protobuf_demo PRIVATE protobuf::libprotoc protobuf::libprotobuf protobuf::libprotobuf-lite)

# # libuv
add_executable(libuv_server "libuv_server.cpp")
target_link_libraries(libuv_server PRIVATE $<IF:$<TARGET_EXISTS:libuv::uv_a>,libuv::uv_a,libuv::uv>)

# # libuv
add_executable(libuv_client "libuv_client.cpp")
target_link_libraries(libuv_client PRIVATE $<IF:$<TARGET_EXISTS:libuv::uv_a>,libuv::uv_a,libuv::uv>)

# # boost
add_executable(boost_demo "boost_demo.cpp")
target_link_libraries(boost_demo PRIVATE Boost::boost)